<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    </style>
</head>
<body>
    <input type="text" name="" id="text"><span id="txt"></span>
    <script>
        function $(e){
            return document.querySelector(e);
        }
        var reg=/^((0\d{2,3}-)|(\(0\d{2,3}\)))?([1-9]\d{6,7})$/
        $('#text').onkeyup=function(){
            if(reg.test(this.value)){
                $('#txt').innerText='OK'
            }else{
                $('#txt').innerText='NO'
            }
        }
    </script>
</body>
</html>